package server

import (
	"context"

	"go-weixin/app/usercenter/rpc/internal/logic"
	"go-weixin/app/usercenter/rpc/internal/svc"
	"go-weixin/app/usercenter/rpc/pb/proto/usercenter"
)

type UserServer struct {
	svcCtx *svc.ServiceContext
	usercenter.UnimplementedUserServer
}

func NewUserServer(svcCtx *svc.ServiceContext) *UserServer {
	return &UserServer{
		svcCtx: svcCtx,
	}
}

// 定义一个 SayHello 一元 rpc 方法，请求体和响应体必填。
func (s *UserServer) Register(ctx context.Context, in *usercenter.RegisterReq) (*usercenter.RegisterResp, error) {
	l := logic.NewUserLogic(ctx, s.svcCtx)
	return l.Register(in)
}

func (s *UserServer) Login(ctx context.Context, in *usercenter.LoginReq) (*usercenter.LoginResp, error) {
	l := logic.NewUserLogic(ctx, s.svcCtx)
	return l.Login(in)
}

func (s *UserServer) UserUpdate(ctx context.Context, in *usercenter.UserUpdateReq) (*usercenter.UserUpdateResp, error) {
	l := logic.NewUserLogic(ctx, s.svcCtx)
	return l.UserUpdate(in)
}

func (s *UserServer) UserAddRole(ctx context.Context, in *usercenter.UserAddRoleReq) (*usercenter.UserAddRoleResp, error) {
	l := logic.NewUserLogic(ctx, s.svcCtx)
	return l.UserAddRole(in)
}
func (s *UserServer) UserUpdateRole(ctx context.Context, in *usercenter.UserUpdateRoleReq) (*usercenter.UserUpdateRoleResp, error) {
	l := logic.NewUserLogic(ctx, s.svcCtx)
	return l.UserUpdateRole(in)
}

func (s *UserServer) UserList(ctx context.Context, in *usercenter.UserListReq) (*usercenter.UserListResp, error) {
	l := logic.NewUserLogic(ctx, s.svcCtx)
	return l.UserList(in)
}

func (s *UserServer) UserDetail(ctx context.Context, in *usercenter.UserDetailReq) (*usercenter.UserDetailResp, error) {
	l := logic.NewUserLogic(ctx, s.svcCtx)
	return l.UserDetail(in)
}

func (s *UserServer) UserGetRole(ctx context.Context, in *usercenter.UserGetRoleReq) (*usercenter.UserGetRoleResp, error) {
	l := logic.NewUserLogic(ctx, s.svcCtx)
	return l.UserGetRole(in)
}

func (s *UserServer) UserGetPower(ctx context.Context, in *usercenter.UserGetPowerReq) (*usercenter.UserGetPowerResp, error) {
	l := logic.NewUserLogic(ctx, s.svcCtx)
	return l.UserGetPower(in)
}
